import request from '@/utils/request'

// 获取公示菜价列表
export function getDishesPriceList(perPage, page) {
  const data = {
    perPage, page
  }
  return request({
    url: 'api/v1/backend/product_price/list',
    method: 'post',
    data
  })
}

// 提交添加菜价
export function submitDishesPrice(productId, price) {
  const data = {
    productId, price
  }
  return request({
    url: 'api/v1/backend/product_price/add',
    method: 'post',
    data
  })
}

// 删除菜品
export function deleteDishesPrice(id) {
  const data = {
    id
  }
  return request({
    url: 'api/v1/backend/product_price/del',
    method: 'post',
    data
  })
}

// 提交修改菜品价格
export function submitEditDishesPrice(data) {
  return request({
    url: 'api/v1/backend/product_price/edit',
    method: 'post',
    data
  })
}


/**
 * 公示广告
 */
// 获取公示广告数据
export function getAdList(searchName, status, adType, machineType, perPage, page) {
  const data = {
    searchName, status, adType, machineType, perPage, page
  }
  return request({
    url: 'api/v1/backend/ad/ad_list',
    method: 'post',
    data
  })
}

// 提交新增广告
export function submitAdversing(type, title, playTime, playUrl, describe, machineType, startDate, endDate){
  const data = {
    type, title, playTime, playUrl, describe, machineType, startDate, endDate
  }
  return request({
    url: 'api/v1/backend/ad/add',
    method: 'post',
    data
  })
}

// 停用广告
export function editAd(id){
  const data = {
    id
  }
  return request({
    url: 'api/v1/backend/ad/edit_end_date',
    method: 'post',
    data
  })
}

// 删除广告
export function deleteAd(id) {
  const data = {
    id
  }
  return request({
    url: 'api/v1/backend/ad/del',
    method: 'post',
    data
  })
}
